import { regs } from '@/utils/validate'

export const registerItems = () => {
  return [
    {
      key: 'phone',
      layoutCol: { sm: 24, md: 24, lg: 24 },
      rules: [
        { pattern: regs.phone, message: '请输入正确的手机号码' },
        { required: true, message: '请输入' }
      ],
      fieldProps: {
        placeholder: '手机号',
        style: 'width: 100%'
      }
    },
    {
      key: 'verifyCode',
      layoutCol: { sm: 16, md: 16, lg: 16 },
      rules: [{ required: true, message: '请输入' }],
      fieldProps: {
        placeholder: '验证码',
        style: 'width: 100%'
      }
    },
    {
      key: 'captcha',
      layoutCol: { sm: 8, md: 8, lg: 8 },
      type: 'slot'
    },
    {
      key: 'newPassword',
      layoutCol: { sm: 24, md: 24, lg: 24 },
      type: 'password',
      rules: [
        { min: 6, message: '长度至少6位', trigger: 'blur' },
        { required: true, message: '请输入' }
      ],
      fieldProps: {
        placeholder: '至少6位密码，区分大小写',
        style: 'width: 100%'
      }
    },
    {
      key: 'confirmPassword',
      type: 'password',
      layoutCol: { sm: 24, md: 24, lg: 24 },
      rules: [
        { min: 6, message: '长度至少6位', trigger: 'blur' },
        { required: true, message: '请输入' }
      ],
      fieldProps: {
        placeholder: '确认密码',
        style: 'width: 100%'
      }
    }
  ]
}

export const editpassItems = () => {
  return [
    {
      key: 'oldPassword',
      label: '',
      layoutCol: { sm: 24, md: 24, lg: 24 },
      type: 'password',
      fieldProps: {
        placeholder: '请输入原密码'
      },
      rules: [{ required: true, message: '请输入' }]
    },
    {
      key: 'newPassword',
      layoutCol: { sm: 24, md: 24, lg: 24 },
      type: 'password',
      label: '',
      fieldProps: {
        placeholder: '请输入新密码'
      },
      rules: [
        { min: 6, message: '长度至少6位', trigger: 'blur' },
        { required: true, message: '请输入' },
        {
          pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*]).{6,20}$/,
          message: '密码长度6-20位，必须包含大小写字母、数字和特殊字符',
          trigger: 'blur'
        }
      ]
    },
    {
      key: 'confirmPassword',
      type: 'password',
      layoutCol: { sm: 24, md: 24, lg: 24 },
      label: '',
      fieldProps: {
        placeholder: '请输入确认新密码'
      },
      rules: [
        { min: 6, message: '长度至少6位', trigger: 'blur' },
        { required: true, message: '请输入' },
        {
          pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*]).{6,20}$/,
          message: '密码长度6-20位，必须包含大小写字母、数字和特殊字符',
          trigger: 'blur'
        }
      ]
    }
  ]
}
